@isTest
private class HF_TriggerTestCases{
static testmethod void triggerTestmethod(){

   test.startTest();
   //creating custom setting...
   
   Global_Defaults__c defaultVal=new Global_Defaults__c(Name='DefaultRelationshipType',default__c='Advisor Contact');
   insert defaultVal;
   
   //Insertion of contact, which will call insertRelationship trigger....
   
   Account a=new Account(name='acc1',Preferred_Country__c='test1',Preferred_Address_Type__c='test2');
   insert a;
   Account a2=new Account(name='acc1',Preferred_Country__c='test1',Preferred_Address_Type__c='test2');
   insert a2;
   Contact c1=new Contact(lastname='test3',accountId=a.Id,Preferred_Address_Type__c='test4',Mail_County__c='test5');
   insert c1;
   
   
   //Updation of contact, which will call updateRelationship trigger....
   Contact c2=[select Id,lastname,accountId,Preferred_Address_Type__c from Contact where Id=:c1.Id];
   c2.accountId=a2.Id;
   update c2;
   
   //to call deleteReation trigger....
   Relationship__c r=new Relationship__c( Account__c=c2.AccountId,Contact__c=c2.Id,Relationship_Type__c=defaultVal.default__c);
    insert r;
    try{
    /* Relationship__c rel=[select Account__c,contact__c,Relationship_Type__c from Relationship__c where Id=:r.Id];
     delete rel;*/
    }catch(Exception e){
        System.debug('Cannot delete contact from relationship.');
    }
    
   // To call preferredAccountAddress...
    
    try{
       /* Account_Address__c accAddress1=new Account_Address__c(Account__c=a.Id,Status__c='Active',Preferred__c=true);
        insert accAddress1;
        Account_Address__c accAddress2=[select name,Status__c,Preferred__c,Account__c from Account_Address__c where Id=:accAddress1.Id];
        update accAddress2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
    // To call preferredAccountEmail...
    
    try{
        /*Account_Email__c accEmail1=new Account_Email__c(Account__c=a.Id,Preferred__c=true);
        insert accEmail1;
        Account_Email__c accEmail2=[select name,Preferred__c,Account__c from Account_Email__c where Id=:accEmail1.Id];
        update accEmail2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
    // To call preferredAccountPhone...
    
    try{
        /*Account_Phone__c accPhone1=new Account_Phone__c(Account__c=a.Id,Status__c='Active',Preferred__c=true);
        insert accPhone1;
        Account_Phone__c accPhone2=[select name,Status__c,Preferred__c,Account__c from Account_Phone__c where Id=:accPhone1.Id];
        update accPhone2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
     // To call preferredContactAddress...
    
    try{
       /* Contact_Address__c conAddress1=new Contact_Address__c(Contact__c=c1.Id,Status__c='Active',Preferred__c=true);
        insert conAddress1;
        Contact_Address__c conAddress2=[select Status__c,Preferred__c,Contact__c from Contact_Address__c where Id=:conAddress1.Id];
        update conAddress2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
    // To call preferredContactEmail...
    
    try{
        /*Contact_Email__c conEmail1=new Contact_Email__c(Contact__c=c1.Id,Preferred__c=true);
        insert conEmail1;
        Contact_Email__c conEmail2=[select Preferred__c,Contact__c from Contact_Email__c where Id=:conEmail1.Id];
        update conEmail2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
    // To call preferredContactPhone...
    
    try{
       /* Contact_Phone__c conPhone1=new Contact_Phone__c(Contact__c=c1.Id,Status__c='Active',Preferred__c=true);
        insert conPhone1;
        Contact_Phone__c conPhone2=[select name,Status__c,Preferred__c,Contact__c from Contact_Phone__c where Id=:conPhone1.Id];
        update conPhone2;*/
    }catch(Exception e){System.debug('There is already one preferred value.');}
    
   test.stopTest();
   }
}